/**
 * 
 */
package com.google.codemirror2_gwt.client.util;

import java.util.List;

import com.google.codemirror2_gwt.client.Cursor;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArrayString;

/**
 * @author Federico De Faveri defaveri@gmail.com
 *
 */
public final class Hints extends JavaScriptObject {


	protected Hints() { }

	public static Hints makeHints(List<String> hints, Cursor from, Cursor to) {
		JsArrayString jsHints = convert(hints);
		return makeHints(jsHints, from, to);
	}

	protected static native Hints makeHints(JsArrayString hints, Cursor from, Cursor to) /*-{
	    return { 'list' : hints, 'from' : from, 'to' : to };
	  }-*/;

	public void setHints(List<String> hints){
		JsArrayString jsHints = convert(hints);
		setHints(jsHints);
	}

	protected static JsArrayString convert(List<String> hints)
	{
		JsArrayString jsHints = (JsArrayString) JavaScriptObject.createArray();
		for (String hint:hints) jsHints.push(hint);
		return jsHints;
	}

	protected native void setHints(JsArrayString hints) /*-{
    	this.list = hints;
  	}-*/;

	public native void setFrom(Cursor from) /*-{
		this.from = from;
	}-*/;

	public native void setTo(Cursor to) /*-{
		this.from = to;
	}-*/;

}
